<template>
  <div class="webview">
    <iframe id="iframe" :src="url" />
  </div>
</template>

<script setup lang='ts'>
const { url } = defineProps<{
  url: string
}>()
onMounted(() => {    // 获取对 iframe 的引用
  const iframe = document.getElementById('iframe');
  const script = document.createElement('script');
  script.textContent = "alert('Hello, World!')";
  iframe?.ownerDocument.appendChild(script);
})
</script>

<style lang="scss" scoped>
.webview {
  #iframe {
    border: none;
    width: 100%;
    height: calc(100vh - 30px);
    overflow: hidden;
    margin-top: 30px !important;
  }
}
</style>